<template>
	<view>
		<uni-card :title="sConf.pos?.nicename"
			:sub-title="fulladdre([sConf.pos?.sheng,sConf.pos?.shi,sConf.pos?.xian,sConf.pos?.zhen,sConf.pos?.address])"
			:extra="title" :thumbnail="avatar">
			<view slot="actions" class="card-actions no-border">
				<text class="uni-body">这是一个带头像和双标题的基础卡片，此示例展示了一个完整的卡片。</text>
			</view>
			<uni-list :border="true" v-for="(item,index) in array" :key="index">
				<uni-list-item :title="item.place.nicename"
					:note="fulladdre([item.place.sheng,item.place.shi,item.place.xian,item.place.zhen,item.place.address])"
					thumb="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png" thumb-size="lg"
					rightText="选择商户" clickable @click="goPos(item.place)"></uni-list-item>
			</uni-list>
		</uni-card>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '当前商户',
				sConf: getApp().globalData,
				avatar: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
				array: null
			}
		},
		mounted() {
			this.queryData();
		},
		methods: {
			onClick(e) {
				console.log(e);
			},
			fulladdre(e) { // 合并商户地址
				var name = "";
				for (var str in e) {
					name += e[str];
				}
				return name;
			},
			goPos(e) {
				this.sConf.pos = e;
				uni.setStorage({
					key: "pos",
					data: e
				});
				uni.$emit('changePos', 1);
			},
			queryData: function(page = 1) {
				var that = this;
				const requestTask = uni.request({
					url: that.sConf.host + '/buss/staffall/',
					method: 'GET',
					header: {
						'content-type': 'application/json',
						'authorization': that.sConf.token
					},
					data: {
						uid: that.sConf.user.id,
						page: page
					},
					success: function(res) {
						if (res.data.rescode == 200) {
							that.array = res.data.resmsg
						}
					}
				});
			}
		}
	}
</script>

<style>

</style>